package com.xbang.attendance.web.action.report.purchaseexecute;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.xbang.attendance.entity.order.PurchaseOrder;
import com.xbang.attendance.entity.system.Region;
import com.xbang.attendance.service.PurchaseOrderService;
import com.demo2do.lighturl.annotation.Action;
import com.xbang.core.page.Result;
import com.xbang.core.struts.support.SearchActionSupport;

public class Search extends SearchActionSupport {
	
	private static final Log logger = LogFactory.getLog(Search.class);
	
	@Autowired
	private PurchaseOrderService purchaseOrderService;
	
	private List<PurchaseOrder> purchaseOrders;
	
	private List<Region> regions = new ArrayList<Region>();

	public String search() throws Exception {
		regions = purchaseOrderService.getObjects(Region.class);

		return "search";
	}
	
	@Action("/report/purchaseexecute/search/do")
	public String doSearch() throws Exception {
		String hqlSentence = " FROM PurchaseOrder purchaseorder WHERE 1 = 1 ";
		Result result = purchaseOrderService.searchByPage(hqlSentence, searchComponent, page);
		purchaseOrders = result.getItems();
		page = result.getPage();

		return "index";
	}
	
	@Override
	public void resetCustomerSearchCriteria() {
		// TODO Auto-generated method stub

	}

	public PurchaseOrderService getPurchaseOrderService() {
		return purchaseOrderService;
	}

	public void setPurchaseOrderService(PurchaseOrderService purchaseOrderService) {
		this.purchaseOrderService = purchaseOrderService;
	}

	public List<PurchaseOrder> getPurchaseOrders() {
		return purchaseOrders;
	}

	public void setPurchaseOrders(List<PurchaseOrder> purchaseOrders) {
		this.purchaseOrders = purchaseOrders;
	}

	public List<Region> getRegions() {
		return regions;
	}

	public void setRegions(List<Region> regions) {
		this.regions = regions;
	}
	
}
